<!--  -->
<template>
  <div class="">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
      <el-row>
        <el-col :span="7">
          <el-input
            placeholder="请输入订单编号"
            clearable
            v-model="query.findKeyWord"
          >
            <el-button
              icon="el-icon-search"
              slot="append"
              @click="searchOrders()"
            ></el-button
          ></el-input>
        </el-col>
      </el-row>
      <el-table :data="ordersList" style="width: 100%" border stripe>
        <el-table-column type="index" label="#"> </el-table-column>
        <el-table-column prop="goodsname" label="订单编号" width="450">
        </el-table-column>
        <el-table-column prop="orderprice" label="订单价格" width="100">
        </el-table-column>
        <el-table-column prop="orderpay" label="是否付款" width="150">
        </el-table-column>
        <el-table-column prop="orderchange" label="是否发货" width="200">
        </el-table-column>
        <el-table-column prop="ordertime" label="下单时间" width="150">
        </el-table-column>
        <el-table-column label="操作" width="150">
          <template>
            <el-button
              size="mini"
              icon="el-icon-edit"
              type="primary"
              @click="showDia()"
            ></el-button>
            <el-button
              size="mini"
              icon="el-icon-location-information"
              type="success"
              @click="Logistics()"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="query.pageNum"
        :page-sizes="[1, 2, 3, 4, 5, 6, 7, 8]"
        :page-size="query.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="count"
      >
      </el-pagination>
    </el-card>

    <el-dialog title="添加分类" :visible.sync="dialogVisible" width="50%" @close="diaClose()">
      <span v-if="isShow">选择省份</span>
      <el-select v-model="cityParmas" clearable placeholder="请选择" v-if="isShow">
        <el-option
          v-for="item in mapdata"
          :key="item.name"
          :label="item.name"
          :value="item.name"
        >
        </el-option>
      </el-select>
        <span v-if="!isShow">物流进度</span>
       
         <el-timeline v-if="!isShow">
    <el-timeline-item
      v-for="(activity, index) in address"
      :key="index"
      :timestamp="activity.time"
      :type="activity.active==1?'success':'info'">
      {{activity.address}}
    </el-timeline-item>
  </el-timeline>


      
    </el-dialog>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      ordersList: [],
      query: {
        pageNum: 1,
        pageSize: 6,
        findKeyWord: "",
      },
      count: 0,
      mapdata: [],
      dialogVisible: false,
      cityParmas:'',
      isShow:true,
      address:[]

    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    async requestOrder() {
      let { data: res } = await this.$http.get("/order", {
        params: this.query,
      });
      console.log(res);
      this.ordersList = res.data;
      this.count = res.count;
      this.$message.success(res.msg);
    },
    searchOrders() {
      this.requestOrder();
    },
    handleSizeChange(e) {
      this.query.pageSize = e;
      this.requestOrder();
    },
    handleCurrentChange(e) {
      this.query.pageNum = e;
      this.requestOrder();
    },
    async mapM() {
      let { data: map } = await this.$http.get("/china");
      console.log(map);

      map.data.features.filter((item) => {
        this.mapdata.push(item.properties);
      });
    },
    showDia() {
      this.dialogVisible = true;
      this.isShow = true
    },
    handleChange() {
      console.log(111);
    },
    diaClose(){
      this.cityParmas = ''
    },
   async Logistics(){
      this.dialogVisible = true;
      this.isShow = false
      let ret =await  this.$http.get('/logistics.json')
      this.address = ret.data
     
    }
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.requestOrder();
    this.mapM();
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
  deactivated() {},
};
</script>
<style  scoped>
  .el-select{
    margin: 10px;
    width: 80%;
  }

</style>